package com.kzw.oa.system.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.security.core.GrantedAuthority;

/**
 * 角色
 * */
@Entity
@Table(name = "app_role")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class AppRole implements GrantedAuthority, Serializable {
	private static final long serialVersionUID = -2783902559358638211L;

	public static String ROLE_PUBLIC = "ROLE_PUBLIC";
	public static String ROLE_ANONYMOUS = "ROLE_ANONYMOUS";

	/**
	 * 超级管理员的角色ID
	 */
	public static final Long SUPER_ROLEID = 1L;
	/**
	 * 超级权限
	 */
	public static final String SUPER_RIGHTS = "__ALL";

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long roleId;

	@Column(unique = true, length = 50)
	private String roleName;

	@Column
	private String roleDesc;

	// status:1 启用
	@Column
	private Integer status;

	// 权限字符串
	@Column(length = 4000)
	private String rights;

	public AppRole() {
	}

	public String getRights() {
		return rights;
	}

	public void setRights(String rights) {
		this.rights = rights;
	}

	public Long getRoleId() {
		return roleId;
	}

	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRoleDesc() {
		return roleDesc;
	}

	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getAuthority() {
		return roleName;
	}

	public int compareTo(Object o) {
		return 0;
	}

	public String getId() {
		return roleId.toString();
	}

	public String getName() {
		return roleName;
	}

}
